<!doctype html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>商城后台管理系统</title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/index.css">
        <link rel="stylesheet" href="./css/iconfont.css">
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./js/index.js"></script>
    
        <style>
            .show_list{display: block !important;}
            .hide_lits{display: none;}

        </style>

    </head>
    <body class="index">
        <!-- 顶部开始 -->
        <div class="container">
            <div class="logo">
                <a href="./index.html">商城后台管理系统</a></div>
            <div class="left_open">
                <a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
            </div>

            <ul class="layui-nav left fast-add" lay-filter="">
                
                <li class="layui-nav-item daohang" ids="#table2">
                    <a href="javascript:;">系统设置</a>

                </li>
            </ul>

            <ul class="layui-nav right" lay-filter="">
               
               
                <li class="layui-nav-item">
                    <a  id="username"></a>
                    <dl class="layui-nav-child">
                        <!-- 二级菜单 -->
                        <dd>
                            <a >个人信息</a></dd>
                        <dd>                  
                             <a href="./login.html">切换帐号</a></dd>
                        <dd>
                            <a onclick="rest()">退出</a></dd>
                    </dl>
                </li>
              
            </ul>



        </div>
        <!-- 顶部结束 -->
        <!-- 中部开始 -->
        <!-- 左侧菜单开始 -->
        <div class="left-nav show_list" id="table1">
            <div id="side-nav">
                <ul id="nav">
                    
  
                </ul>
            </div>
        </div>
        <!-- <div class="x-slide_left"></div> -->

       

        <!-- 左侧菜单结束 -->
        <!-- 右侧主体开始 -->
        <div class="page-content">
            <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
                <ul class="layui-tab-title">
                    <li class="home">
                        <i class="layui-icon">&#xe68e;</i>我的桌面</li></ul>
                <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
                    <dl>
                        <dd data-type="this">关闭当前</dd>
                        <dd data-type="other">关闭其它</dd>
                        <dd data-type="all">关闭全部</dd></dl>
                </div>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <iframe src='./welcome.html' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
                    </div>
                </div>
                <div id="tab_show"></div>
            </div>
        </div>
        <div class="page-content-bg"></div>
        <style id="theme_style"></style>
        <!-- 右侧主体结束 -->
        <!-- 中部结束 -->

    </body>
    <script src="js/jquery.min.js"></script>

</html>

<script>

      
	   selectusername();
	   
	   //查询用户名并且填充
	          function  selectusername(){
	          	  $.ajax({
					url: 'http://localhost:16111/user/selectmydata',
					type: 'get',
					dataType: 'json',
					data:{userid:getCookie("userid")},
					success: function(data) {
						
							$('#username').html(data.userData.user_name);
					}
				});
	          }
               
				
				
				
	   selects();
    	//模糊查询
    	function selects(){   		
    		$.ajax({
    			type:"get",
    			url:"http://localhost:16111/memurbac/reachbyuseridmemu",
    			dataType:"json",   
    			data:{userid:getCookie("userid")},
    			xhrFields:{withCredentials: true},
    			success:function(res){
    				//表示为查询成功，
    				if(res.code==200){	
    					   	//添加菜单列表
    		          	
    					for(var i in res.data){
    						
    						if(res.data[i].memu_name=="后台管理菜单-max"){
    							
    							var data=res.data[i];
    							//alert(JSON.stringify(data.childMemu));
    							child(data,document.getElementById("nav"));
    							
    						}
    						
    						
    					}
    					        
    					
    				}else{
    					
    					layui.use("layer", function () {
                //提示错误信息
    					layer.msg(res.error,{icon:7,time:1000});
             })

    					
    				
    				}
    			},
    			error:function(error){
    			
    				layui.use("layer", function (){
             	//提示错误信息
    				layer.msg(JSON.stringify(error),{icon:2,time:1000});
             })
    				
    			}
    		});
    		
   
    	}
	
    $(".daohang").click(function(){
        var table = $(this).attr("ids");
        var ids = $(".show_list").attr("id");
        $("#"+ids+"").addClass("hide_lits");
        $("#"+ids+"").removeClass("show_list");
        $(""+table+"").removeClass("hide_lits");
        $(""+table+"").addClass("show_list");
    })

   	
     	//退出登录,
      function	rest(){
          
      	
      	//清除token
     	 document.cookie="token=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=localhost";
     	 document.cookie="userid=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=localhost";
     		
     	//刷新本页面
     	location.href="login.html";
     	}

function child(data,dom){
	if(data.childMemu!=null){
		var childen =data.childMemu;
	
		for (var i = 0; i < childen.length; i++) {
			
			
    	         
    	         if(childen[i].memu_url==""){                          
    	         	 var str="<a href=\"javascript:;\">"+
                                    "<i class=\"iconfont left-nav-li\" lay-tips=\""+childen[i].memu_name+"\">&#xe6a7;</i>"+
                                    "<cite>"+childen[i].memu_name+"</cite>"+                         
                                    "</a>";
                
                var li=document.createElement("li");  
    	         li.innerHTML=str;
    	       
    	         }else{
    	         	 var str="<a onclick=\"xadmin.add_tab(\'"+childen[i].memu_name+"\',\'"+childen[i].memu_url+"\')\">"+
                                    "<i class=\"iconfont\">&#xe6a7;</i>"+
                                    "<cite>"+childen[i].memu_name+"</cite></a>";
                
                  var li=document.createElement("li");  
    	         li.innerHTML=str;
    	         	
    	         }
    	  
			
				if(data.memu_url==""&&dom.id!="nav"){
			var ul=document.createElement("ul"); 
    	         ul.className="sub-menu";
    	         ul.appendChild(li);
    	          dom.appendChild(ul);
    	           child(childen[i],ul);
		}else{
			 dom.appendChild(li);
			  child(childen[i],li);
		   }
		
		 
		
		}
		
		
		
		
	}else{
		return ;
	}
}


 
      function getCookie(cookieName) {
			var strCookie = document.cookie;
			var arrCookie = strCookie.split("; ");
			for(var i = 0; i < arrCookie.length; i++) {
				var arr = arrCookie[i].split("=");
				if(cookieName == arr[0]) {
					return arr[1];
				}
			}
			return "";
		}
</script>

<script>
//清除历史打开记录
    close();
     function close(){
     	 window.onload=close; 
     	 $('.layui-tab-title li[lay-id]').find('.layui-tab-close').click();        
        $('#tab_right').hide();
        $('#tab_show').hide();
     }

</script>
